Replace configure events with a GdkSurface::size-changed signal.
This is part of the move to use events only for input.
return event->pad_axis.time;
case GDK_PAD_GROUP_MODE:
return event->pad_group_mode.time;
- case GDK_CONFIGURE:
case GDK_FOCUS_CHANGE:
case GDK_NOTHING:
case GDK_DELETE:
case GDK_LEAVE_NOTIFY:
*state = event->crossing.state;
return TRUE;
- case GDK_CONFIGURE:
case GDK_FOCUS_CHANGE:
case GDK_PROXIMITY_IN:
case GDK_PROXIMITY_OUT:
switch ((guint) event->any.type)
{
- case GDK_CONFIGURE:
- x = event->configure.x;
- y = event->configure.y;
- break;
case GDK_ENTER_NOTIFY:
case GDK_LEAVE_NOTIFY:
x = event->crossing.x;
switch ((guint) event->any.type)
{
- case GDK_CONFIGURE:
- event->configure.x = x;
- event->configure.y = y;
- break;
case GDK_ENTER_NOTIFY:
case GDK_LEAVE_NOTIFY:
event->crossing.x = x;
typedef struct _GdkEventKey GdkEventKey;
typedef struct _GdkEventFocus GdkEventFocus;
typedef struct _GdkEventCrossing GdkEventCrossing;
-typedef struct _GdkEventConfigure GdkEventConfigure;
typedef struct _GdkEventProximity GdkEventProximity;
typedef struct _GdkEventDND GdkEventDND;
typedef struct _GdkEventSetting GdkEventSetting;
* @GDK_ENTER_NOTIFY: the pointer has entered the surface.
* @GDK_LEAVE_NOTIFY: the pointer has left the surface.
* @GDK_FOCUS_CHANGE: the keyboard focus has entered or left the surface.
- * @GDK_CONFIGURE: the size, position or stacking order of the surface has changed.
- * Note that GTK+ discards these events for %GDK_SURFACE_CHILD surfaces.
* @GDK_MAP: the surface has been mapped.
* @GDK_UNMAP: the surface has been unmapped.
* @GDK_PROXIMITY_IN: an input device has moved into contact with a sensing
GDK_ENTER_NOTIFY,
GDK_LEAVE_NOTIFY,
GDK_FOCUS_CHANGE,
- GDK_CONFIGURE,
GDK_MAP,
GDK_UNMAP,
GDK_PROXIMITY_IN,
gint16 in;
};
-/*
- * GdkEventConfigure:
- * @type: the type of the event (%GDK_CONFIGURE).
- * @surface: the surface which received the event.
- * @send_event: %TRUE if the event was sent explicitly.
- * @x: the new x coordinate of the surface, relative to its parent.
- * @y: the new y coordinate of the surface, relative to its parent.
- * @width: the new width of the surface.
- * @height: the new height of the surface.
- *
- * Generated when a surface size or position has changed.
- */
-struct _GdkEventConfigure
-{
- GdkEventAny any;
- gint x, y;
- gint width;
- gint height;
-};
-
/*
* GdkEventProximity:
* @type: the type of the event (%GDK_PROXIMITY_IN or %GDK_PROXIMITY_OUT).
* @key: a #GdkEventKey
* @crossing: a #GdkEventCrossing
* @focus_change: a #GdkEventFocus
- * @configure: a #GdkEventConfigure
* @proximity: a #GdkEventProximity
* @dnd: a #GdkEventDND
* @grab_broken: a #GdkEventGrabBroken
GdkEventKey key;
GdkEventCrossing crossing;
GdkEventFocus focus_change;
- GdkEventConfigure configure;
GdkEventProximity proximity;
GdkEventDND dnd;
GdkEventGrabBroken grab_broken;
enum {
MOVED_TO_RECT,
+ SIZE_CHANGED,
LAST_SIGNAL
};
G_TYPE_POINTER,
G_TYPE_BOOLEAN,
G_TYPE_BOOLEAN);
+
+ signals[SIZE_CHANGED] =
+ g_signal_new (g_intern_static_string ("size-changed"),
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ 0,
+ NULL,
+ NULL,
+ NULL,
+ G_TYPE_NONE,
+ 2,
+ G_TYPE_INT,
+ G_TYPE_INT);
}
static void
{
cairo_region_t *old_region, *new_region;
gboolean expose;
+ gboolean size_changed;
g_return_if_fail (GDK_IS_SURFACE (surface));
/* Handle child surfaces */
expose = FALSE;
+ size_changed = FALSE;
old_region = NULL;
if (gdk_surface_is_viewable (surface) &&
}
if (!(width < 0 && height < 0))
{
- surface->width = width;
- surface->height = height;
+ if (surface->width != width)
+ {
+ surface->width = width;
+ size_changed = TRUE;
+ }
+ if (surface->height != height)
+ {
+ surface->height = height;
+ size_changed = TRUE;
+ }
}
recompute_visible_regions (surface, FALSE);
cairo_region_destroy (old_region);
cairo_region_destroy (new_region);
}
-}
-
+ if (size_changed)
+ g_signal_emit (surface, signals[SIZE_CHANGED], 0, width, height);
+}
/**
* gdk_surface_move:
break;
case GDK_FOCUS_CHANGE:
- case GDK_CONFIGURE:
case GDK_MAP:
case GDK_UNMAP:
case GDK_DELETE:
int height,
int scale)
{
- GdkDisplay *display;
- GdkEvent *event;
-
- event = gdk_event_new (GDK_CONFIGURE);
- event->any.surface = g_object_ref (surface);
- event->any.send_event = FALSE;
- event->configure.width = width;
- event->configure.height = height;
-
gdk_wayland_surface_update_size (surface, width, height, scale);
_gdk_surface_update_size (surface);
-
- display = gdk_surface_get_display (surface);
- _gdk_wayland_display_deliver_event (display, event);
+ g_signal_emit_by_name (surface, "size-changed", width, height);
}
static gboolean
return_val = FALSE;
else
{
- event->any.type = GDK_CONFIGURE;
- event->any.surface = surface;
- event->configure.width = (xevent->xconfigure.width + surface_impl->surface_scale - 1) / surface_impl->surface_scale;
- event->configure.height = (xevent->xconfigure.height + surface_impl->surface_scale - 1) / surface_impl->surface_scale;
+ int x, y, width, height;
+ x = 0;
+ y = 0;
+ width = (xevent->xconfigure.width + surface_impl->surface_scale - 1) / surface_impl->surface_scale;
+ height = (xevent->xconfigure.height + surface_impl->surface_scale - 1) / surface_impl->surface_scale;
if (!xevent->xconfigure.send_event &&
!xevent->xconfigure.override_redirect &&
!GDK_SURFACE_DESTROYED (surface))
&tx, &ty,
&child_window))
{
- event->configure.x = tx / surface_impl->surface_scale;
- event->configure.y = ty / surface_impl->surface_scale;
+ x = tx / surface_impl->surface_scale;
+ y = ty / surface_impl->surface_scale;
}
gdk_x11_display_error_trap_pop_ignored (display);
}
else
{
- event->configure.x = xevent->xconfigure.x / surface_impl->surface_scale;
- event->configure.y = xevent->xconfigure.y / surface_impl->surface_scale;
+ x = xevent->xconfigure.x / surface_impl->surface_scale;
+ y = xevent->xconfigure.y / surface_impl->surface_scale;
}
+
if (!is_substructure)
{
- surface->x = event->configure.x;
- surface->y = event->configure.y;
+ surface->x = x;
+ surface->y = y;
if (surface_impl->unscaled_width != xevent->xconfigure.width ||
surface_impl->unscaled_height != xevent->xconfigure.height)
{
surface_impl->unscaled_width = xevent->xconfigure.width;
surface_impl->unscaled_height = xevent->xconfigure.height;
- surface->width = event->configure.width;
- surface->height = event->configure.height;
+ surface->width = width;
+ surface->height = height;
_gdk_surface_update_size (surface);
_gdk_x11_surface_update_size (surface_impl);
+
+ g_signal_emit_by_name (surface, "size-changed", width, height);
}
if (surface->resize_count >= 1)
if (surface->resize_count == 0)
_gdk_x11_moveresize_configure_done (display, surface);
- }
+ }
}
+
+ return_val = FALSE;
}
break;
GdkEvent *event,
StatusWindow *status_window)
{
+#if 0
if (gdk_event_get_event_type (event) == GDK_CONFIGURE)
{
GdkRectangle rect;
gtk_window_move (GTK_WINDOW (status_window->window), rect.x, y);
}
}
+#endif
return GDK_EVENT_PROPAGATE;
}
}
break;
- case GDK_CONFIGURE:
- if (GTK_IS_WINDOW (event_widget) &&
- _gtk_widget_get_surface (event_widget) == event->any.surface)
- {
- gtk_window_configure (GTK_WINDOW (event_widget),
- event->configure.width,
- event->configure.height);
- }
-
- break;
case GDK_FOCUS_CHANGE:
case GDK_UNMAP:
case GDK_GRAB_BROKEN:
case GDK_NOTHING:
case GDK_DELETE:
case GDK_DESTROY:
- case GDK_CONFIGURE:
case GDK_MAP:
case GDK_UNMAP:
return gtk_widget_emit_event_signals (widget, event);
gtk_widget_set_surface (widget, surface);
g_signal_connect_swapped (surface, "notify::state", G_CALLBACK (surface_state_changed), widget);
+ g_signal_connect_swapped (surface, "size-changed", G_CALLBACK (gtk_window_configure), widget);
gtk_widget_register_surface (widget, surface);
GTK_WIDGET_CLASS (gtk_window_parent_class)->realize (widget);
g_signal_handlers_disconnect_by_func (_gtk_widget_get_surface (widget),
G_CALLBACK (surface_state_changed),
widget);
+ g_signal_handlers_disconnect_by_func (_gtk_widget_get_surface (widget),
+ G_CALLBACK (gtk_window_configure),
+ widget);
GTK_WIDGET_CLASS (gtk_window_parent_class)->unrealize (widget);
static GtkWidget *default_height_spin;
static GtkWidget *resizable_check;
-static gboolean
-configure_event_cb (GtkWidget *window, GdkEvent *event, GtkLabel *label)
+static void
+configure_event_cb (GtkWidget *window, int width, int height, GtkLabel *label)
{
- if (gdk_event_get_event_type (event) == GDK_CONFIGURE)
- {
- gchar *str;
- gint width, height;
-
- gtk_window_get_size (GTK_WINDOW (window), &width, &height);
- str = g_strdup_printf ("%d x %d", width, height);
- gtk_label_set_label (label, str);
- g_free (str);
- }
-
- return GDK_EVENT_PROPAGATE;
+ gchar *str;
+
+ str = g_strdup_printf ("%d x %d", width, height);
+ gtk_label_set_label (label, str);
+ g_free (str);
}
static void
//gtk_widget_show (label);
gtk_dialog_add_action_widget (GTK_DIALOG (dialog), label, GTK_RESPONSE_HELP);
- g_signal_connect (dialog, "event",
+ gtk_widget_realize (dialog);
+ g_signal_connect (gtk_widget_get_surface (dialog), "size-changed",
G_CALLBACK (configure_event_cb), label);
gtk_dialog_run (GTK_DIALOG (dialog));